package junior.sample.support.db;

import junior.db.dao.update.DeleteOption;
import junior.db.dao.update.UpdateOption;
import junior.db.spi.EntityPersistenceService;
import junior.sample.support.db.option.D;
import junior.sample.support.db.option.U;

/**
 * @author wubo
 * @date 2024/9/2 17:32
 */
public class MyEntityPersistenceService implements EntityPersistenceService {
    
    @Override
    public void beforeInsert(Object entity) {
        System.out.println("before insert entity: " + entity);
    }
    
    @Override
    public void beforeUpdate(Object entity) {
        System.out.println("before update entity: " + entity);
    }
    
    @Override
    public String[] getExcludeInsertFields(Object entity) {
        return new String[0];
    }
    
    @Override
    public String[] getExcludeUpdateFields(Object entity) {
        return new String[]{"id", "createTime", "createdBy"};
    }
    
    @Override
    public UpdateOption getUpdateOption(Class<?> entityClass) {
        return new U();
    }
    
    @Override
    public DeleteOption getDeleteOption(Class<?> entityClass) {
        return new D();
    }
    
}
